package view;

import model.*;


import java.awt.Dimension;
import java.awt.Graphics;
import java.util.*;

/**
 * A BreadBoard megjelenítéséért felelős osztály.
 *
 */
public class BreadBoardView extends javax.swing.JPanel implements view.Paintable {

	private static final long serialVersionUID = 1328069997311073026L;
	
	public BreadBoard breadboard;
	public List<Paintable> blocks;
	public List<Paintable> wires;
	public List<Paintable> inputs;
	public List<Paintable> outputs;
	
	/**
	 * Az egér kattintások mind a BradBoardra érkeznek, ezen  a map-on keresztül tudja értesíteni az ott lévő dolgokat a BB.
	 */
	Map<Dimension,Paintable> coordinates;
	
	public BreadBoardView(BreadBoard breadboard){
		super();
		
		this.breadboard = breadboard;
		
		this.blocks = new ArrayList<Paintable>(); 
		this.wires = new ArrayList<Paintable>(); 		
		this.inputs = new ArrayList<Paintable>(); 
		this.outputs = new ArrayList<Paintable>(); 
		this.coordinates = new HashMap<Dimension,Paintable>();		
				
		this.setBorder(new javax.swing.border.LineBorder(java.awt.Color.BLACK));
		this.setBackground(java.awt.Color.WHITE);
	}
	
	
	/**
	* visszaadja a paraméter megadott elemhez tartozó View objektumot
	*/
	public Paintable getViewForBlock(BuildingBlock b){
		
		return null;
	}
	
	/**
	 * visszaadja a paraméter megadott vezetékhez tartozó View objektumot
	 * @param w
	 * @return
	 */
	public Paintable getViewForWire(Wire w){
		
		return null;
	}
	
	/**
	 * visszaadja a paraméter megadott inputhoz tartozó View objektumot
	 * @param i
	 * @return
	 */
	public Paintable getViewForInput(Input i){
		
		return null;
	}
	
	/**
	 * visszaadja a paraméter megadott outputhoz tartozó View objektumot
	 * @param o
	 * @return
	 */
	public Paintable getViewForOutput(Output o){
		
		return null;
	}
	
	/**
	 * meghívja minden blokkon a paint() metódust
	 */
	public void repaint(Graphics g){
		for (Paintable p : this.blocks){
			p.paint(g);
		}
		for (Paintable p : this.wires){
			p.paint(g);
		}		
	}
	
	@Override
	public void paint(Graphics g){
		super.paint(g);
		for(int i=5; i< this.getWidth()-3 ; i+=10){
			for(int j=5; j< this.getHeight()-3 ; j+=10){
				g.setColor(java.awt.Color.LIGHT_GRAY);
				g.drawRect(i, j, 1, 1);
			}
		}		
		repaint(g);		
	}


	public List<Paintable> getBlocks() {
		return blocks;
	}


	public void setBlocks(List<Paintable> blocks) {
		this.blocks = blocks;
	}


	public List<Paintable> getWires() {
		return wires;
	}


	public void setWires(List<Paintable> wires) {
		this.wires = wires;
	}



	
	
}
